package com.dianping.cat.alarm.sender.transform;

import com.dianping.cat.alarm.sender.entity.Par;
import com.dianping.cat.alarm.sender.entity.Sender;
import com.dianping.cat.alarm.sender.entity.SenderConfig;
import org.xml.sax.Attributes;







public class DefaultSaxMaker
  extends Object
  implements IMaker<Attributes>
{
  public Par buildPar(Attributes attributes) {
/* 19 */     String id = attributes.getValue("id");
/* 20 */     Par par = new Par();

/* 22 */     if (id != null) {
/* 23 */       par.setId(id);
    }

/* 26 */     return par;
  }


  public Sender buildSender(Attributes attributes) {
/* 31 */     String id = attributes.getValue("id");
/* 32 */     String url = attributes.getValue("url");
/* 33 */     String type = attributes.getValue("type");
/* 34 */     String successCode = attributes.getValue("successCode");
/* 35 */     String batchSend = attributes.getValue("batchSend");
/* 36 */     Sender sender = new Sender(id);

/* 38 */     if (url != null) {
/* 39 */       sender.setUrl(url);
    }

/* 42 */     if (type != null) {
/* 43 */       sender.setType(type);
    }

/* 46 */     if (successCode != null) {
/* 47 */       sender.setSuccessCode(successCode);
    }

/* 50 */     if (batchSend != null) {
/* 51 */       sender.setBatchSend(((Boolean)convert(Boolean.class, batchSend, Boolean.valueOf(false))).booleanValue());
    }

/* 54 */     return sender;
  }



/* 59 */   public SenderConfig buildSenderConfig(Attributes attributes) { return new SenderConfig(); }





  protected <T> T convert(Class<T> type, String value, T defaultValue) {
/* 66 */     if (value == null || value.length() == 0) {
/* 67 */       return defaultValue;
    }

/* 70 */     if (type == Boolean.class || type == boolean.class)
/* 71 */       return (T)Boolean.valueOf(value); 
/* 72 */     if (type == Integer.class || type == int.class)
/* 73 */       return (T)Integer.valueOf(value); 
/* 74 */     if (type == Long.class || type == long.class)
/* 75 */       return (T)Long.valueOf(value); 
/* 76 */     if (type == Short.class || type == short.class)
/* 77 */       return (T)Short.valueOf(value); 
/* 78 */     if (type == Float.class || type == float.class)
/* 79 */       return (T)Float.valueOf(value); 
/* 80 */     if (type == Double.class || type == double.class)
/* 81 */       return (T)Double.valueOf(value); 
/* 82 */     if (type == Byte.class || type == byte.class)
/* 83 */       return (T)Byte.valueOf(value); 
/* 84 */     if (type == Character.class || type == char.class) {
/* 85 */       return (T)Character.valueOf(value.charAt(0));
    }
/* 87 */     return (T)value;
  }
}


/* Location:              /Users/hanfei/Documents/apache-tomcat-9.0.24/webapps/cat/WEB-INF/lib/cat-alarm-3.0.0.jar!/com/dianping/cat/alarm/sender/transform/DefaultSaxMaker.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       1.0.7
 */